package cn.iocoder.yudao.module.crm.dal.mysql.subject;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crm.dal.dataobject.subject.SubjectDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crm.controller.admin.subject.vo.*;

/**
 * 栏目 Mapper
 *
 * @author zuo
 */
@Mapper
public interface SubjectMapper extends BaseMapperX<SubjectDO> {

    default List<SubjectDO> selectList(SubjectListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SubjectDO>()
                .likeIfPresent(SubjectDO::getName, reqVO.getName())
                .eqIfPresent(SubjectDO::getStatus, reqVO.getStatus()));
    }

    default PageResult<SubjectDO> selectPage(SubjectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SubjectDO>()
                .eqIfPresent(SubjectDO::getParentId, reqVO.getParentId())
                .likeIfPresent(SubjectDO::getName, reqVO.getName())
                .eqIfPresent(SubjectDO::getUrl, reqVO.getUrl())
                .eqIfPresent(SubjectDO::getSort, reqVO.getSort())
                .eqIfPresent(SubjectDO::getLevel, reqVO.getLevel())
                .eqIfPresent(SubjectDO::getDisplay, reqVO.getDisplay())
                .eqIfPresent(SubjectDO::getStatus, reqVO.getStatus())
                .eqIfPresent(SubjectDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(SubjectDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SubjectDO::getId));
    }

    /**
     * 根据ID查询所有子ID，包含自己
     * @return
     */
    Set<Long> selectSubjectIdListById(Long id);



}